#!/usr/bin/env python
# -*- coding:utf-8 -*-

from multiprocessing import Process, Lock

def f(l, i):
    l.acquire()
    try:
        print('hello world', i)
    finally:
        l.release()

if __name__ == '__main__':
    lock = Lock()
    process = None
    for num in range(10):
        process = Process(target=f, args=(lock, num))
        process.start()
    process.join()